<?php
/**
*
 * 版权所有：河南常新宏达网络科技<www.hncxhd.com>
 * 作    者：zxl
 * 日    期：2017-2-10
 * 版    本：1.0.0
* 功能说明：数据库备份、还原控制器。
*
**/

namespace Admin\Controller;
use Admin\Controller\ComController;
use Think\Upload;  
use Think\Auth;

class DateimportController extends ComController {

    public function index(){
        //$this->readfile();
        $this -> display();
    }


 public function upload() {  
    $result=upload('files');
    if( stristr($result, 'Uploads')){
        //$this->success('文件上传成功');
        $this->assign('result','文件上传成功');
        $filename=$result;
        $this->assign('result',$result);
        $this->readfile($filename);
        session('filesname', $filename);
       // $this->readfile();
    }
    else{
        $this->assign('result',$result);
    }
   $this->display();
 }


///////duwu execl数据
public function readfile($files) {  
        /////////////////加载phpexecl库
        $this->importPhpexecl();
      if(isset($files)){
         $file_name=".".$files;  //session('filesname');
         $objReader = \PHPExcel_IOFactory::createReader('Excel5');
         $objPHPExcel = $objReader->load($file_name,$encode='utf-8');
         $sheet = $objPHPExcel->getSheet(0);
         $highestRow = $sheet->getHighestRow(); // 取得总行数
         $highestColumn = $sheet->getHighestColumn(); // 取得总列数
         $tablehead=array();
       for($col="A";$col<=$highestColumn;$col++){
          $tablehead[]=$sheet->getCell($col.'1')->getValue();
         }
         $this->assign("tableheads",$tablehead);
       
      }

                           
    }


}